// Author: Fu huizhong<fuhuizn@163.com>
package gsort

type Compareable interface {
	int | int8 | int16 | int32 | int64 | float32 | float64 | string
}

func Sort[T Compareable](s []T) {
	n := len(s)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			if s[i] > s[j] {
				s[i], s[j] = s[j], s[i]
			}
		}
	}
}

func IsSorted[T Compareable](s []T) bool {
	n := len(s) - 1
	for i := 0; i < n; i++ {
		if s[i] > s[i+1] {
			return false
		}
	}
	return true
}
